# 728 简单：自除数

class Solution:
    # def selfDividingNumbers(self, left: int, right: int) -> List[int]:
    def selfDividingNumbers(self, left: int, right: int):
        # ret = [i for i in range(left, right + 1)]
        # for i in range(left, right + 1):
        #     temp = i
        #     while temp != 0:
        #         if temp % 10 == 0:
        #             ret.remove(i)
        #             break
        #         if i % (temp % 10) != 0:
        #             ret.remove(i)
        #             break
        #         temp = int(temp / 10)
        # return ret

        def isSelfDividing(num: int) -> bool:
            x = num
            while x:
                x, d = divmod(x, 10)
                if d == 0 or num % d:
                    return False
            return True

        return [i for i in range(left, right + 1) if isSelfDividing(i)]


s = Solution()
print(s.selfDividingNumbers(47, 85))
